package com.yunfeisoft.business.dao.impl.postgres;

import com.applet.base.ServiceDaoImpl;
import com.applet.sql.builder.WhereBuilder;
import com.applet.utils.Page;
import com.yunfeisoft.business.dao.inter.SmsHomeRecommendProductDao;
import com.yunfeisoft.business.model.SmsHomeRecommendProduct;
import org.springframework.stereotype.Repository;
import org.springframework.util.ObjectUtils;

import java.util.List;
import java.util.Map;

/**
 * ClassName: SmsHomeRecommendProductDaoImpl
 * Description: 人气推荐商品表Dao实现
 * Author: Jackie liu
 * Date: 2020-06-02
 */
@Repository
public class SmsHomeRecommendProductDaoImpl extends ServiceDaoImpl<SmsHomeRecommendProduct, String> implements SmsHomeRecommendProductDao {

    @Override
    public Page<SmsHomeRecommendProduct> queryPage(Map<String, Object> params) {
        WhereBuilder wb = new WhereBuilder();
        wb.setOrderByWithDesc("createTime");
        if (params != null) {
            if (!ObjectUtils.isEmpty(params.get("name"))) {
                wb.andFullLike("productName", params.get("name"));
            }
            initPageParam(wb, params);
        }
        return queryPage(wb);
    }

    @Override
    public List<SmsHomeRecommendProduct> queryByProductId(String productId) {
        WhereBuilder wb = new WhereBuilder();
        wb.andEquals("productId", productId);
        return query(wb);
    }
}